
<!DOCTYPE html>
<html lang="en" style="font-size: 54.8px;"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<title>欢乐口红机</title>
<!--<base href="{:env('host')}/static/game_h5/" target="_blank">-->
<base href="https://static.jxqianbao.com/game_h5/" target="_blank">
<link rel="stylesheet" href="https://static.jxqianbao.com/game_h5/css/game.css?v=1.0">
<script>
        var kh_version_number = "?v=1.0";
    </script>
<script type="text/javascript" src="js/bodymovin.js?v=1.0"></script>
<script type="text/javascript" src="js/jweixin-1.3.2.js?v=1.0"></script>
<script typet="text/javascript" src="js/jquery.js?v=1.0"></script>
<script type="text/javascript" src="js/cookie.js?v=1.0"></script>
<script type="text/javascript" src="js/touch.js?v=1.0"></script>
<script type="text/javascript" src="js/demogame.js?v=1.1"></script>
<script type="text/javascript" src="js/demo.js?v=1.2"></script>
</head>
<body>

<div class="levelSwitchBox" id="levelSwitchBox">
<img id="levelSwitchBoxMain" class="levelSwitchBoxMain" src="img/level_1_mains.png?v=1.0">
</div>
<div class="PopupBox" id="gameOverBox" style="display: none;">
<div id="gameOverBoxTitle">闯关失败</div>
<div class="PopupBoxBtn" id="gameOverBoxBtn">重新闯关</div>
</div>
<div class="PopupBox" id="gameErrorBox" style="display: none;">
    <div id="gameErrorBoxTitle">您的系统有异常</div>
<div class="PopupBoxBtn" id="gameErrorBoxBtn">返回</div>
</div>
<div class="PopupBox" id="gameSuccessBox" style="display: none;">
<div id="gameSuccessBoxText">体验结束</div>
<div class="PopupBoxBtn" id="gameSuccessBoxBtn">返回开始游戏</div>
</div>

<!-- 音乐 -->
<!-- <div id="musicbox"></div> -->

<div class="layoutRoot" id="app" style="background-image: url('img/bg.png?v=1.0');background-repeat: no-repeat;background-size: cover;">
<div class="game" id="game" style="width: 411px; height: 731px;">
<div class="account">
<span></span>
</div>
<div class="bulletsNumBox">
<img class="bulletsNum" id="bulletsNum1" src="img/6.png?v=1.0">
</div>
<canvas style="position: relative;z-index: 3" id="gameStage" width="411" height="731"></canvas>
<div id="bm" style="width: 100%; height: 100%;position: fixed;background-color: rgba(0,0,0,0);top: 5.3rem; transform: translate(-5%,-1%); z-index: 2">
</div>
<div class="tips">
<p id="currentLevel">当前关数: <span>1</span></p>
<p id="gameTip"></p>
</div>
<div class="levelbox" id="levelbox">
<div class="level"><img id="level_1" src="img/level_icon_1_active.png?v=1.0"></div>
<div class="level"><img id="level_2" src="img/level_icon_2.png?v=1.0"></div>
<div class="level"><img id="level_3" src="img/level_3.png?v=1.0"></div>
</div>

<div id="timebox">18</div>
</div>
</div>
<audio id="back_music" preload="" src="music/bg_audio.mp3" loop="true"></audio>
<audio id="split_audio" preload="" src="music/split_audio.mp3"></audio>
<audio id="collision_audio" preload="" src="music/collision_audio.mp3"></audio>
<audio id="Countdown_10s_audio" preload="" src="music/Countdown_10s_audio.mp3"></audio>
<audio id="gameFail_audio" preload="" src="music/gameFail_audio.mp3"></audio>
<audio id="gameSuccess_audio" preload="" src="music/gameSuccess_audio.mp3"></audio>
<audio id="insert_audio" preload="" src="music/insert_audio.mp3"></audio>
<audio id="success_audio" preload="" src="music/success_audio.mp3"></audio>
<script type="text/javascript">
    var loadedMusic = false;
    document.body.addEventListener('touchmove', function (e) {
        e.preventDefault(); //阻止默认的处理方式(阻止下拉滑动的效果)
    }, {passive: false});
    var baseUrl = function GetRequest() {
        var url = location.search;  //获取url中"?"符后的字符串
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
            url = url.split("?")[1];
            strs = url.split("&");
            for (var i = 0; i < strs.length; i++) {
                theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
            }
        }
        return theRequest;

    }
    var jsonParamsAlias = baseUrl();
     var jsonParams = {
         "game_id" : jsonParamsAlias.gid,
         "game_pay" : jsonParamsAlias.pay,
         "product_id" : jsonParamsAlias.pid,
         "randomNum" : jsonParamsAlias.rand,
         "forecast_result": jsonParamsAlias.res,
         "user_id" : jsonParamsAlias.uid
     }
    if (jsonParamsAlias.slient) {
        $('audio').prop('muted', true);
    }
    if (jsonParamsAlias.h5 && jsonParamsAlias.h5 == "1") {
        window.isH5 = true;
    }
    var cookieDelTime = new Date(Math.floor(new Date(new Date().getTime()+150000)));
    $.cookie('game_cookie', null);
    $.cookie('game_cookie', JSON.stringify(jsonParams), { expires: cookieDelTime });
    var anim = bodymovin.loadAnimation({
        wrapper: document.querySelector('#bm'),
        animType: 'svg',
        loop: false,
        autoplay: false,
        prerender: true,
        path: 'jsons/data.json'
    });
    function play(){
        anim.goToAndStop(0, true)
        anim.play()
    }
    document.addEventListener('DOMContentLoaded', function () {
         // iOS 音乐问题
        if (!!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) {
            
            $('audio').each(function () {
                var that = this;
                function musicInBrowserHandler() {
                    that.play();
                    that.pause();
                    document.body.removeEventListener('touchstart', musicInBrowserHandler);
                }
                document.body.addEventListener('touchstart', musicInBrowserHandler);
            })
            
        }
        // function audioAutoPlay() {
        //     var audio = document.getElementById('back_music');
        //     try {
        //         audio.play();
        //     } catch (error) {
        //         console.log(error)
        //     }
        //     document.addEventListener("WeixinJSBridgeReady", function () {
        //         audio.play();
        //     }, false);
        // }

        function audioAutoPlay() {

            // function musicInBrowserHandler() {
            //     musicPlay(true);
            //     document.body.removeEventListener('touchstart', musicInBrowserHandler);
            // }
            // document.body.addEventListener('touchstart', musicInBrowserHandler);

            // function musicInWeixinHandler() {
            //     musicPlay(true);
            //     document.addEventListener("WeixinJSBridgeReady", function () {
            //         musicPlay(true);
            //     }, false);
            //     document.removeEventListener('DOMContentLoaded', musicInWeixinHandler);
            // }
            // document.addEventListener('DOMContentLoaded', musicInWeixinHandler);
            function musicInBrowserHandler() {
                var audio = document.getElementById('back_music');
                audio.play();
                document.body.removeEventListener('touchstart', musicInBrowserHandler);
            }
            document.body.addEventListener('touchstart', musicInBrowserHandler);

        }
        // function musicPlay(isPlay) {
	    //     var audio = document.getElementById('back_music');
	    //     if (isPlay && audio.paused) {
        //         audio.play();
        //         $('#musicbox').removeClass('pause');
	    //     }
	    //     if (!isPlay && !audio.paused) {
        //         audio.pause();
        //         $('#musicbox').addClass('pause');
	    //     }
	    // }
        // autoPlayMusic();
        audioAutoPlay();
    });
    // 音乐点击事件
//   document.getElementById('musicbox').addEventListener('click',function (e) {
//         window.event? window.event.cancelBubble = true : e.stopPropagation();
//         var audio = document.getElementById('back_music');
//         $('#musicbox').toggleClass('pause')
// 	    if (audio.paused) {
//             audio.play();
//             console.log('打开音乐');
// 	    }
// 	    if (!audio.paused) {
//             audio.pause();
// 	    }
//     }, false);
   

    document.addEventListener('visibilitychange', function(e) {
        function audioStop() {
            var audio = document.getElementById('back_music');
            document.hidden ? audio.pause() : audio.play();
            document.addEventListener("WeixinJSBridgeReady", function () {
                document.hidden ? audio.pause() : audio.play();
            }, false);
        }
        audioStop();
    });

</script>
</body></html>